package com.huayal.mall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.huayal.common.validator.ListValue;
import com.huayal.common.validator.group.AddGroup;
import com.huayal.common.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *  后端校验：1，添加依赖 2，controller类添加@Valid启动实体校验   3，在实体类添加类似@NotBlank注解
 * @author huayal
 * @email efry@qq.com
 * @date 2024-11-01 20:00:04
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @NotNull(message = "更新品牌数据ID不能为空",groups = {UpdateGroup.class})
    @Null(message = "提交品牌信息ID必须为空",groups = {AddGroup.class})
    @TableId
    private Long brandId;
    /**
     * 品牌名
     */
    @NotNull(groups = UpdateGroup.class)
    @NotBlank(message = "品牌名不能为空",groups = {AddGroup.class,UpdateGroup.class})
    private String name;
    /**
     * 品牌logo地址
     */
    @NotNull(message = "logo不能为空",groups = {AddGroup.class,UpdateGroup.class})
    @URL(message = "logo必须是一个合法的url地址",groups = {AddGroup.class,UpdateGroup.class})
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @NotNull(message = "显示状态不能为空",groups = AddGroup.class)
    @ListValue(val = {0,1},groups = {AddGroup.class,UpdateGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    @NotNull(message = "检索首字母不能为空",groups = {AddGroup.class,UpdateGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$",message="检索首字母必须是单个字母",groups = {AddGroup.class,UpdateGroup.class})//可自定义
    private String firstLetter;
    /**
     * 排序
     */
    @NotNull(message = "排序不能为null",groups = {AddGroup.class,UpdateGroup.class})
    @Min(value = 0,message = "排序不能小于0",groups = {AddGroup.class,UpdateGroup.class})
    private Integer sort;

}
